﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.LogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public abstract class LogEntry
  {
    protected const uint NotificationDefaultTextColor = 0;

    protected virtual void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      CampaignTime.AutoGeneratedStaticCollectObjectsCampaignTime((object) this.GameTime, collectedObjects);
    }

    internal static object AutoGeneratedGetMemberValueId(object o) => (object) ((LogEntry) o).Id;

    internal static object AutoGeneratedGetMemberValueGameTime(object o)
    {
      return (object) ((LogEntry) o).GameTime;
    }

    [SaveableProperty(0)]
    public long Id { get; private set; }

    [SaveableProperty(1)]
    public CampaignTime GameTime { get; private set; }

    public virtual CampaignTime KeepInHistoryTime => CampaignTime.Days(7f);

    public virtual ChatNotificationType NotificationType => ChatNotificationType.Default;

    protected ChatNotificationType MilitaryNotification(IFaction benefiter, IFaction affected)
    {
      if (benefiter == Clan.PlayerClan)
        return ChatNotificationType.PlayerClanPositive;
      if (affected == Clan.PlayerClan)
        return ChatNotificationType.PlayerClanNegative;
      if (benefiter?.MapFaction == Clan.PlayerClan.MapFaction)
        return ChatNotificationType.PlayerFactionPositive;
      if (affected?.MapFaction == Clan.PlayerClan.MapFaction)
        return ChatNotificationType.PlayerFactionNegative;
      if (affected != null && affected.IsAtWarWith(Clan.PlayerClan.MapFaction))
        return ChatNotificationType.PlayerFactionIndirectPositive;
      return benefiter != null && benefiter.IsAtWarWith(Clan.PlayerClan.MapFaction) ? ChatNotificationType.PlayerFactionIndirectNegative : ChatNotificationType.Neutral;
    }

    protected ChatNotificationType DiplomaticNotification(IFaction faction1, IFaction faction2)
    {
      if (faction1 == Clan.PlayerClan || faction2 == Clan.PlayerClan)
        return ChatNotificationType.PlayerClanPositive;
      if (faction1 == Clan.PlayerClan.MapFaction || faction2 == Clan.PlayerClan.MapFaction)
        return ChatNotificationType.PlayerFactionPositive;
      return faction1 != null && Clan.PlayerClan.MapFaction.IsAtWarWith(faction1) || faction2 != null && Clan.PlayerClan.MapFaction.IsAtWarWith(faction2) ? ChatNotificationType.PlayerFactionIndirectNegative : ChatNotificationType.PlayerFactionIndirectPositive;
    }

    protected ChatNotificationType AdversityNotification(IFaction faction1, IFaction faction2)
    {
      if (faction1 == Clan.PlayerClan || faction2 == Clan.PlayerClan)
        return ChatNotificationType.PlayerClanNegative;
      return faction1?.MapFaction == Clan.PlayerClan.MapFaction || faction2?.MapFaction == Clan.PlayerClan.MapFaction ? ChatNotificationType.PlayerFactionNegative : ChatNotificationType.Neutral;
    }

    protected ChatNotificationType PoliticalNotification(IFaction faction)
    {
      if (faction == Clan.PlayerClan)
        return ChatNotificationType.PlayerClanPolitical;
      return faction?.MapFaction == Clan.PlayerClan.MapFaction ? ChatNotificationType.PlayerFactionPolitical : ChatNotificationType.Political;
    }

    protected ChatNotificationType CivilianNotification(IFaction faction)
    {
      if (faction == Clan.PlayerClan)
        return ChatNotificationType.PlayerClanCivilian;
      return faction?.MapFaction == Clan.PlayerClan.MapFaction ? ChatNotificationType.PlayerFactionCivilian : ChatNotificationType.Civilian;
    }

    public static void AddLogEntry(LogEntry logEntry)
    {
      logEntry.GameTime = CampaignTime.Now;
      logEntry.Id = ++Campaign.Current.LogEntryHistory.LastAddedIndex;
      Campaign.Current.LogEntryHistory.AddActionLog(logEntry);
    }

    public static void AddLogEntry(LogEntry logEntry, CampaignTime gameTime)
    {
      logEntry.GameTime = gameTime;
      logEntry.Id = ++Campaign.Current.LogEntryHistory.LastAddedIndex;
      Campaign.Current.LogEntryHistory.AddActionLog(logEntry, true);
    }

    public virtual ImportanceEnum GetImportanceForClan(Clan clan) => ImportanceEnum.Zero;

    public virtual void GetConversationScoreAndComment(
      Hero talkTroop,
      bool findString,
      out string comment,
      out ImportanceEnum score)
    {
      comment = "";
      score = ImportanceEnum.Zero;
    }

    public virtual int GetAsRumor(Settlement settlement, ref TextObject comment) => 0;

    public virtual TextObject GetHistoricComment(Hero talkTroop) => TextObject.Empty;

    public virtual int AsReasonForEnmity(Hero referenceHero1, Hero referenceHero2) => 0;

    public virtual int GetValueAsPoliticsAbuseOfPower(Hero referenceTroop, Hero liege) => 0;

    public virtual int GetValueAsPoliticsSlightedClan(Hero referenceTroop, Hero liege) => 0;

    public virtual int GetValueAsPoliticsShowedWeakness(Hero referenceTroop, Hero liege) => 0;
  }
}
